package com.mysoft.gfyx.marketdevelop.controller;

import com.mysoft.framework.common.exception.BusinessLogicException;
import com.mysoft.framework.rpc.annotation.PubAction;
import com.mysoft.framework.rpc.annotation.PubService;
import com.mysoft.framework.rpc.contants.RequestPrefix;
import com.mysoft.gfyx.marketdevelop.controller.dto.MarketReportingRequestDto;
import com.mysoft.gfyx.marketdevelop.mip.dto.SearchDeveloperRequestDto;
import com.mysoft.gfyx.marketdevelop.service.DMPService;
import com.mysoft.gfyx.marketdevelop.service.DeveloperService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.HashMap;
import java.util.Map;

@PubService(value = "/dmpDataApi", prefix = RequestPrefix.API)
@Tag(name = "数见DMP-API")
public class DMPDataApiController {


    @Autowired
    private DMPService dmpService;

    @PubAction(value = "/getLoginUrl", method = RequestMethod.POST)
    public Object getLoginUrl(@RequestBody MarketReportingRequestDto dto) {
        MultiValueMap<String, String> q = new LinkedMultiValueMap<>();
        q.add("date", dto.getYear().toString());
        q.add("province_code", dto.getProvinceCode());

        DMPService.DMPPage page;
        switch (dto.getPage()) {
            case "land":
                page = DMPService.DMPPage.Land;
                break;
            case "project":
                page = DMPService.DMPPage.Project;
                break;
            case "procurement":
                page = DMPService.DMPPage.Procurement;
                break;
            case "work":
                page = DMPService.DMPPage.Work;
                break;
            case "dashboard":
                page = DMPService.DMPPage.Dashboard;
                break;
            case "usage":
                page = DMPService.DMPPage.Usage;
                break;
            case "user_application_board":
                return dmpService.getLoginUrlV2();
            case "market_monthly_report":
                page = DMPService.DMPPage.MarketMonthlyReport;
                break;
            default:
                throw new BusinessLogicException("你必须指定正确的Page");
        }
        return dmpService.getLoginUrl(page, q);
    }

}
